package com.lang.management;

import java.lang.management.ManagementFactory;
import java.lang.management.OperatingSystemMXBean;
import java.lang.management.RuntimeMXBean;

public class MXDemo {
	
	/**
	 * 可获得系统cpu线程数
	 */
	public static void operatingSystemMXBean() {
		OperatingSystemMXBean operatingSystemMXBean = ManagementFactory.getOperatingSystemMXBean();
		int processors = operatingSystemMXBean.getAvailableProcessors();
		System.out.println(processors);
	}
	
	/**
	 * 可获得当前进程id
	 */
	public static void runtimeMXBean() {
		RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
		// 6744@Ackles-PC
		String name = runtimeMXBean.getName();
		System.out.println(name);
	}
}
